< previous page page_979 next page >

Page 979
4. You use the SELECT_INTO_FROM SQL statement to create new tables and insert existing data from other tables. The format of this statement is
SELECT field1, field2 INTO DestinationTable FROM SourceTable;
In this statement, field1 and field2 represent the field names in the source table.
5. You use the DELETE_FROM statement to remove records from a data table. The form of this statement is
DELETE FROM TableName WHERE field = value;
Answers to Day 15 Exercises
1. Enter the following INSERT_INTO statements after your CREATE INDEX statement to insert the data.
INSERT INTO CustomerType VALUES('INDV', 'Individual');
INSERT INTO CustomerType VALUES('BUS', 'Business - Non-corporate');
INSERT INTO CustomerType VALUES('CORP', 'Corporate Entity');
INSERT INTO Customers VALUES('SMITHJ', 'John Smith', 'INDV',
     '160 Main Street', 'Dublin', 'Ohio', '45621',
     '614-569-8975', '614-569-5580');
INSERT INTO Customers VALUES('JONEST', 'Jones Taxi', 'BUS',
     '421 Shoe St.', 'Milford', 'Rhode Island', '03215',
     '401-737-4528', '401-667-8900');
INSERT INTO Customers VALUES('JACKSONT', 'Thomas Jackson', 'INDV',
     '123 Walnut Street', 'Oxford', 'Maine', '05896',
     '546-897-8596', '546-897-8500');
2. Your script should now look like this:
// Create the database
dbmake C:\CUSTOMER\CH15EX.MDB;
// Build the Customer Types Table
CREATE TABLE CustomerType(
     CustomerType TEXT(6) CONSTRAINT PKCustomerType PRIMARY KEY,
     Description TEXT(30));
// Build the Customers table
CREATE TABLE Customers(
     CustomerID TEXT(10) Constraint PKCustomerID PRIMARY KEY,
     Name TEXT(30),
     CustomerType TEXT(6) CONSTRAINT FKCustomerType REFERENCES
      _CustomerType(CustomerType),
     Address TEXT(30),
     City TEXT(30),
     State TEXT(30),
     Zip TEXT(10),
     Phone TEXT(14),
     Fax TEXT(14));
// Build the index on Zip
CREATE INDEX SKZip on Customers(Zip);
// Insert Data
INSERT INTO CustomerType VALUES('INDV', 'Individual');
INSERT INTO CustomerType VALUES('BUS', 'Business - Non-corporate');
INSERT INTO CustomerType VALUES('CORP', 'Corporate Entity');

 
< previous page page_979 next page >

If you like this book, buy it!